import service from '@/utils/request';

// 获取部门列表
export function getDepartments() {
    console.log('请求URL:', service.defaults.baseURL + '/departments');
    return service.get('/departments');
}

// 新增部门（修正参数结构）
export function addDepartment(data) {
    return service.post('/departments', {
        deptId: data.deptId,
        deptName: data.deptName,
        managerId: data.managerId || null
    });
}

// 更新部门（修正URL参数）
export function updateDepartment(data) {
    return service.put(`/departments/${data.deptId}`, {
        deptName: data.deptName,
        managerId: data.managerId
    });
}

// 删除部门
export function deleteDepartment(id) {
    return service.delete(`/departments/${id}`);
}
